package com.telit.firecommand.controller;

import com.telit.common.entity.DataReturn;
import com.telit.firecommand.dto.GeoPkFdiRdAreaDto;
import com.telit.firecommand.dto.GeoPkFdiRdHotPortAreaNewDto;
import com.telit.firecommand.dto.GeoPkFdiRdResponsibilityZoneDto;
import com.telit.firecommand.service.IGeoPkFdiRdService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yummy
 * @since 2021-08-05
 */
@RestController
@RequestMapping("/geo-pk-fdi-rd")
@Api(tags = "热点",description = "/geo-pk-fdi-rd")
public class GeoPkFdiRdController {

    private Logger log = LoggerFactory.getLogger(getClass());

    @Resource
    private IGeoPkFdiRdService geoPkFdiRdService;

    /**
     * 根据等级分组统计面积
     * @param flag 是否需要dj=1的低等级统计数据，1是需要，0是不需要
     * @param dayFlag 1：今天、昨天、前天；2：明天；3:后天
     * @param date 日期
     * @return
     */
    @GetMapping("/statisticAreaByDJ")
    @ApiOperation("根据等级分组统计面积")
    @ApiImplicitParams({@ApiImplicitParam(name="flag",value = "是否需要dj=1的低等级统计数据，1是需要，0是不需要",dataType = "integer",paramType = "query"),
            @ApiImplicitParam(name="dayFlag",value = "1：今天、昨天、前天；2：明天；3:后天",dataType = "integer",paramType = "query"),
            @ApiImplicitParam(name="date",value = "日期",dataType = "string",paramType = "query")})
    public DataReturn statisticAreaByDJ(@RequestParam(value = "flag",required = false) Integer flag,
                                        @RequestParam(value = "dayFlag") Integer dayFlag,
                                        @RequestParam(value = "date",required = false)  String date,
                                        @RequestParam(value = "districtCode",required = true)  String districtCode

                                        ){
        List<GeoPkFdiRdAreaDto> geoPkFdiRdAreaDtoList=geoPkFdiRdService.statisticAreaByDJ(flag,dayFlag,date,districtCode);
        return DataReturn.ok(geoPkFdiRdAreaDtoList);
    }

    @GetMapping("/statisticAreaByHotPortAndDJ")
    @ApiOperation("根据热点和等级统计面积")
    @ApiImplicitParams({@ApiImplicitParam(name="level",value = "等级",dataType = "integer",paramType = "query"),
            @ApiImplicitParam(name="dayFlag",value = "1：今天、昨天、前天；2：明天；3:后天",dataType = "integer",paramType = "query"),
            @ApiImplicitParam(name="date",value = "日期",dataType = "string",paramType = "query"),
            @ApiImplicitParam(name="countryName",value = "村名",dataType = "string",paramType = "query")})
    public DataReturn statisticAreaByHotPortAndDJ(Integer level,Integer dayFlag,String date,@RequestParam(required = false) String countryName,  @RequestParam(value = "districtCode",required = true)  String districtCode) throws InterruptedException {
        List<GeoPkFdiRdHotPortAreaNewDto> geoPkFdiRdHotPortAreaDtoList=geoPkFdiRdService.statisticAreaByHotPortAndDJ(level,dayFlag,date,countryName, districtCode );
        return DataReturn.ok(geoPkFdiRdHotPortAreaDtoList);
    }

    @GetMapping("/statisticAreaByResponsibilityZone")
    @ApiOperation("根据责任区统计面积")
    @ApiImplicitParams({@ApiImplicitParam(name="level",value = "等级",dataType = "integer",paramType = "query"),
            @ApiImplicitParam(name="dayFlag",value = "1：今天、昨天、前天；2：明天；3:后天",dataType = "integer",paramType = "query"),
            @ApiImplicitParam(name="date",value = "日期",dataType = "string",paramType = "query"),
            @ApiImplicitParam(name="countryName",value = "村名",dataType = "string",paramType = "query")})
    public DataReturn statisticAreaByResponsibilityZone(Integer level,Integer dayFlag,String date,@RequestParam(required = false) String countryName, @RequestParam(value = "districtCode",required = true)  String districtCode) throws InterruptedException {
        List<GeoPkFdiRdResponsibilityZoneDto> geoPkFdiRdResponsibilityZoneDtoList=geoPkFdiRdService.statisticAreaByResponsibilityZone(level,dayFlag,date,countryName,districtCode);
        return DataReturn.ok(geoPkFdiRdResponsibilityZoneDtoList);
    }

    @GetMapping(value = "/selectMjByYjidAndCun",produces = "application/json;charset=UTF-8")
    @ApiOperation("根据村code和热点编号查询热点面积")
    public DataReturn selectMjByYjidAndCun(@RequestParam("dayFlag") Integer dayFlag,
                                           @RequestParam(value = "cunCode",required = false) String cunCode,
                                           @RequestParam("yjid") String yjid,
                                           @RequestParam("date") String date,
                                           @RequestParam(value = "districtCode",required = true)  String districtCode){
        List<GeoPkFdiRdAreaDto> geoPkFdiRdAreaDto = geoPkFdiRdService.selectMjByYjidAndCun(dayFlag,cunCode,yjid,date,districtCode);
        return DataReturn.ok(geoPkFdiRdAreaDto);
    }
}
